<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>module URI - uri: Ruby Standard Library Documentation</title>


<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<script src="./js/jquery-3.2.0.min.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/js.cookie.min.js"></script>

<link href="./css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="./css/rdoc.css" rel="stylesheet">
<link href="./css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
  var darkModeCsseHref = "./css/rdoc-dm.css"
  var defaultModeCssHref = "./css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="module">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="./index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    
<div class="nav-section">
  <h3>Table of Contents</h3>

  <ul class="link-list" role="directory">
    <li><a href="#module-URI-label-Features">Features</a>
    <li><a href="#module-URI-label-Basic+example">Basic example</a>
    <li><a href="#module-URI-label-Adding+custom+URIs">Adding custom URIs</a>
    <li><a href="#module-URI-label-RFC+References">RFC References</a>
    <li><a href="#module-URI-label-Class+tree">Class tree</a>
    <li><a href="#module-URI-label-Copyright+Info">Copyright Info</a>
  </ul>
</div>


    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><a class="include" href="URI/RFC2396_REGEXP.html">URI::RFC2396_REGEXP</a>
  </ul>
</div>

        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-_decode_uri_component">::_decode_uri_component</a>
    <li ><a href="#method-c-_encode_uri_component">::_encode_uri_component</a>
    <li ><a href="#method-c-decode_uri_component">::decode_uri_component</a>
    <li ><a href="#method-c-decode_www_form">::decode_www_form</a>
    <li ><a href="#method-c-decode_www_form_component">::decode_www_form_component</a>
    <li ><a href="#method-c-encode_uri_component">::encode_uri_component</a>
    <li ><a href="#method-c-encode_www_form">::encode_www_form</a>
    <li ><a href="#method-c-encode_www_form_component">::encode_www_form_component</a>
    <li ><a href="#method-c-for">::for</a>
    <li ><a href="#method-c-join">::join</a>
    <li ><a href="#method-c-parse">::parse</a>
    <li ><a href="#method-c-register_scheme">::register_scheme</a>
    <li ><a href="#method-c-scheme_list">::scheme_list</a>
    <li ><a href="#method-c-split">::split</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="module-URI">
    <h1 id="module-URI" class="module">
      module URI
    </h1>

    <section class="description">
    
<p><a href="URI.html"><code>URI</code></a> is a module providing classes to handle Uniform Resource Identifiers (<a href="http://tools.ietf.org/html/rfc2396">RFC2396</a>).</p>

<h2 id="module-URI-label-Features">Features<span><a href="#module-URI-label-Features">&para;</a> <a href="#top">&uarr;</a></span></h2>
<ul><li>
<p>Uniform way of handling URIs.</p>
</li><li>
<p>Flexibility to introduce custom <a href="URI.html"><code>URI</code></a> schemes.</p>
</li><li>
<p>Flexibility to have an alternate <a href="URI/RFC2396_Parser.html"><code>URI::Parser</code></a> (or just different patterns and regexp’s).</p>
</li></ul>

<h2 id="module-URI-label-Basic+example">Basic example<span><a href="#module-URI-label-Basic+example">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">&#39;uri&#39;</span>

<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>(<span class="ruby-string">&quot;http://foo.com/posts?id=30&amp;limit=5#time=1305298413&quot;</span>)
<span class="ruby-comment">#=&gt; #&lt;URI::HTTP http://foo.com/posts?id=30&amp;limit=5#time=1305298413&gt;</span>

<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span>    <span class="ruby-comment">#=&gt; &quot;http&quot;</span>
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">host</span>      <span class="ruby-comment">#=&gt; &quot;foo.com&quot;</span>
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>      <span class="ruby-comment">#=&gt; &quot;/posts&quot;</span>
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span>     <span class="ruby-comment">#=&gt; &quot;id=30&amp;limit=5&quot;</span>
<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">fragment</span>  <span class="ruby-comment">#=&gt; &quot;time=1305298413&quot;</span>

<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">to_s</span>      <span class="ruby-comment">#=&gt; &quot;http://foo.com/posts?id=30&amp;limit=5#time=1305298413&quot;</span>
</pre>

<h2 id="module-URI-label-Adding+custom+URIs">Adding custom URIs<span><a href="#module-URI-label-Adding+custom+URIs">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre class="ruby"><span class="ruby-keyword">module</span> <span class="ruby-constant">URI</span>
  <span class="ruby-keyword">class</span> <span class="ruby-constant">RSYNC</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">Generic</span>
    <span class="ruby-constant">DEFAULT_PORT</span> = <span class="ruby-value">873</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">register_scheme</span> <span class="ruby-string">&#39;RSYNC&#39;</span>, <span class="ruby-constant">RSYNC</span>
<span class="ruby-keyword">end</span>
<span class="ruby-comment">#=&gt; URI::RSYNC</span>

<span class="ruby-constant">URI</span>.<span class="ruby-identifier">scheme_list</span>
<span class="ruby-comment">#=&gt; {&quot;FILE&quot;=&gt;URI::File, &quot;FTP&quot;=&gt;URI::FTP, &quot;HTTP&quot;=&gt;URI::HTTP,</span>
<span class="ruby-comment">#    &quot;HTTPS&quot;=&gt;URI::HTTPS, &quot;LDAP&quot;=&gt;URI::LDAP, &quot;LDAPS&quot;=&gt;URI::LDAPS,</span>
<span class="ruby-comment">#    &quot;MAILTO&quot;=&gt;URI::MailTo, &quot;RSYNC&quot;=&gt;URI::RSYNC}</span>

<span class="ruby-identifier">uri</span> = <span class="ruby-constant">URI</span>(<span class="ruby-string">&quot;rsync://rsync.foo.com&quot;</span>)
<span class="ruby-comment">#=&gt; #&lt;URI::RSYNC rsync://rsync.foo.com&gt;</span>
</pre>

<h2 id="module-URI-label-RFC+References">RFC References<span><a href="#module-URI-label-RFC+References">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>A good place to view an RFC spec is <a href="http://www.ietf.org/rfc.html">www.ietf.org/rfc.html</a>.</p>

<p>Here is a list of all related RFC’s:</p>
<ul><li>
<p><a href="http://tools.ietf.org/html/rfc822">RFC822</a></p>
</li><li>
<p><a href="http://tools.ietf.org/html/rfc1738">RFC1738</a></p>
</li><li>
<p><a href="http://tools.ietf.org/html/rfc2255">RFC2255</a></p>
</li><li>
<p><a href="http://tools.ietf.org/html/rfc2368">RFC2368</a></p>
</li><li>
<p><a href="http://tools.ietf.org/html/rfc2373">RFC2373</a></p>
</li><li>
<p><a href="http://tools.ietf.org/html/rfc2396">RFC2396</a></p>
</li><li>
<p><a href="http://tools.ietf.org/html/rfc2732">RFC2732</a></p>
</li><li>
<p><a href="http://tools.ietf.org/html/rfc3986">RFC3986</a></p>
</li></ul>

<h2 id="module-URI-label-Class+tree">Class tree<span><a href="#module-URI-label-Class+tree">&para;</a> <a href="#top">&uarr;</a></span></h2>
<ul><li>
<p><a href="URI/Generic.html"><code>URI::Generic</code></a> (in uri/generic.rb)</p>
<ul><li>
<p><a href="URI/File.html"><code>URI::File</code></a> - (in uri/file.rb)</p>
</li><li>
<p><a href="URI/FTP.html"><code>URI::FTP</code></a> - (in uri/ftp.rb)</p>
</li><li>
<p><a href="URI/HTTP.html"><code>URI::HTTP</code></a> - (in uri/http.rb)</p>
<ul><li>
<p><a href="URI/HTTPS.html"><code>URI::HTTPS</code></a> - (in uri/https.rb)</p>
</li></ul>
</li><li>
<p><a href="URI/LDAP.html"><code>URI::LDAP</code></a> - (in uri/ldap.rb)</p>
<ul><li>
<p><a href="URI/LDAPS.html"><code>URI::LDAPS</code></a> - (in uri/ldaps.rb)</p>
</li></ul>
</li><li>
<p><a href="URI/MailTo.html"><code>URI::MailTo</code></a> - (in uri/mailto.rb)</p>
</li></ul>
</li><li>
<p><a href="URI/RFC2396_Parser.html"><code>URI::Parser</code></a> - (in uri/common.rb)</p>
</li><li>
<p><a href="URI/RFC2396_REGEXP.html"><code>URI::REGEXP</code></a> - (in uri/common.rb)</p>
<ul><li>
<p>URI::REGEXP::PATTERN - (in uri/common.rb)</p>
</li></ul>
</li><li>
<p>URI::Util - (in uri/common.rb)</p>
</li><li>
<p><a href="URI/Error.html"><code>URI::Error</code></a> - (in uri/common.rb)</p>
<ul><li>
<p><a href="URI/InvalidURIError.html"><code>URI::InvalidURIError</code></a> - (in uri/common.rb)</p>
</li><li>
<p><a href="URI/InvalidComponentError.html"><code>URI::InvalidComponentError</code></a> - (in uri/common.rb)</p>
</li><li>
<p><a href="URI/BadURIError.html"><code>URI::BadURIError</code></a> - (in uri/common.rb)</p>
</li></ul>
</li></ul>

<h2 id="module-URI-label-Copyright+Info">Copyright Info<span><a href="#module-URI-label-Copyright+Info">&para;</a> <a href="#top">&uarr;</a></span></h2>
<dl class="rdoc-list note-list"><dt>Author
<dd>
<p>Akira Yamada &lt;akira@ruby-lang.org&gt;</p>
</dd><dt>Documentation
<dd>
<p>Akira Yamada &lt;akira@ruby-lang.org&gt; Dmitry V. Sabanin &lt;sdmitry@lrn.ru&gt; Vincent Batts &lt;vbatts@hashbangbash.com&gt;</p>
</dd><dt>License
<dd>
<p>Copyright © 2001 akira yamada &lt;akira@ruby-lang.org&gt; You can redistribute it and/or modify it under the same term as Ruby.</p>
</dd></dl>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="DEFAULT_PARSER">DEFAULT_PARSER
          <dd><p><a href="URI/RFC2396_Parser.html#method-c-new"><code>URI::Parser.new</code></a></p>
          <dt id="INITIAL_SCHEMES">INITIAL_SCHEMES
          <dd>
          <dt id="Parser">Parser
          <dd>
          <dt id="REGEXP">REGEXP
          <dd>
          <dt id="RFC3986_PARSER">RFC3986_PARSER
          <dd>
          <dt id="TBLENCURICOMP_">TBLENCURICOMP_
          <dd>
        </dl>
        </section>



                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-decode_uri_component" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">decode_uri_component</span><span
                                class="method-args">(str, enc=Encoding::UTF_8)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Like <a href="URI.html#method-c-decode_www_form_component"><code>URI.decode_www_form_component</code></a>, except that <code>&#39;+&#39;</code> is preserved.</p>

                              <div class="method-source-code" id="decode_uri_component-source">
            <pre><span class="ruby-comment"># File uri/common.rb, line 379</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">decode_uri_component</span>(<span class="ruby-identifier">str</span>, <span class="ruby-identifier">enc</span>=<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>)
  <span class="ruby-identifier">_decode_uri_component</span>(<span class="ruby-regexp">/%\h\h/</span>, <span class="ruby-identifier">str</span>, <span class="ruby-identifier">enc</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-decode_www_form" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">decode_www_form</span><span
                                class="method-args">(str, enc=Encoding::UTF_8, separator: &#39;&amp;&#39;, use__charset_: false, isindex: false)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns name/value pairs derived from the given string <code>str</code>, which must be an ASCII string.</p>

<p>The method may be used to decode the body of Net::HTTPResponse object <code>res</code> for which <code>res[&#39;Content-Type&#39;]</code> is <code>&#39;application/x-www-form-urlencoded&#39;</code>.</p>

<p>The returned data is an array of 2-element subarrays; each subarray is a name/value pair (both are strings). Each returned string has encoding <code>enc</code>, and has had invalid characters removed via String#scrub.</p>

<p>A simple example:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">decode_www_form</span>(<span class="ruby-string">&#39;foo=0&amp;bar=1&amp;baz&#39;</span>)
<span class="ruby-comment"># =&gt; [[&quot;foo&quot;, &quot;0&quot;], [&quot;bar&quot;, &quot;1&quot;], [&quot;baz&quot;, &quot;&quot;]]</span>
</pre>

<p>The returned strings have certain conversions, similar to those performed in <a href="URI.html#method-c-decode_www_form_component"><code>URI.decode_www_form_component</code></a>:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">decode_www_form</span>(<span class="ruby-string">&#39;f%23o=%2F&amp;b-r=%24&amp;b+z=%40&#39;</span>)
<span class="ruby-comment"># =&gt; [[&quot;f#o&quot;, &quot;/&quot;], [&quot;b-r&quot;, &quot;$&quot;], [&quot;b z&quot;, &quot;@&quot;]]</span>
</pre>

<p>The given string may contain consecutive separators:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">decode_www_form</span>(<span class="ruby-string">&#39;foo=0&amp;&amp;bar=1&amp;&amp;baz=2&#39;</span>)
<span class="ruby-comment"># =&gt; [[&quot;foo&quot;, &quot;0&quot;], [&quot;&quot;, &quot;&quot;], [&quot;bar&quot;, &quot;1&quot;], [&quot;&quot;, &quot;&quot;], [&quot;baz&quot;, &quot;2&quot;]]</span>
</pre>

<p>A different separator may be specified:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">decode_www_form</span>(<span class="ruby-string">&#39;foo=0--bar=1--baz&#39;</span>, <span class="ruby-value">separator:</span> <span class="ruby-string">&#39;--&#39;</span>)
<span class="ruby-comment"># =&gt; [[&quot;foo&quot;, &quot;0&quot;], [&quot;bar&quot;, &quot;1&quot;], [&quot;baz&quot;, &quot;&quot;]]</span>
</pre>

                              <div class="method-source-code" id="decode_www_form-source">
            <pre><span class="ruby-comment"># File uri/common.rb, line 554</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">decode_www_form</span>(<span class="ruby-identifier">str</span>, <span class="ruby-identifier">enc</span>=<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>, <span class="ruby-value">separator:</span> <span class="ruby-string">&#39;&amp;&#39;</span>, <span class="ruby-value">use__charset_:</span> <span class="ruby-keyword">false</span>, <span class="ruby-value">isindex:</span> <span class="ruby-keyword">false</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;the input of #{self.name}.#{__method__} must be ASCII only string&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">str</span>.<span class="ruby-identifier">ascii_only?</span>
  <span class="ruby-identifier">ary</span> = []
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">ary</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">str</span>.<span class="ruby-identifier">empty?</span>
  <span class="ruby-identifier">enc</span> = <span class="ruby-constant">Encoding</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">enc</span>)
  <span class="ruby-identifier">str</span>.<span class="ruby-identifier">b</span>.<span class="ruby-identifier">each_line</span>(<span class="ruby-identifier">separator</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">string</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">string</span>.<span class="ruby-identifier">chomp!</span>(<span class="ruby-identifier">separator</span>)
    <span class="ruby-identifier">key</span>, <span class="ruby-identifier">sep</span>, <span class="ruby-identifier">val</span> = <span class="ruby-identifier">string</span>.<span class="ruby-identifier">partition</span>(<span class="ruby-string">&#39;=&#39;</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">isindex</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">sep</span>.<span class="ruby-identifier">empty?</span>
        <span class="ruby-identifier">val</span> = <span class="ruby-identifier">key</span>
        <span class="ruby-identifier">key</span> = <span class="ruby-string">+&#39;&#39;</span>
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">isindex</span> = <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">use__charset_</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">key</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;_charset_&#39;</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">e</span> = <span class="ruby-identifier">get_encoding</span>(<span class="ruby-identifier">val</span>)
      <span class="ruby-identifier">enc</span> = <span class="ruby-identifier">e</span>
      <span class="ruby-identifier">use__charset_</span> = <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">key</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp">/\+|%\h\h/</span>, <span class="ruby-constant">TBLDECWWWCOMP_</span>)
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">val</span>
      <span class="ruby-identifier">val</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp">/\+|%\h\h/</span>, <span class="ruby-constant">TBLDECWWWCOMP_</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">val</span> = <span class="ruby-string">+&#39;&#39;</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">ary</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">key</span>, <span class="ruby-identifier">val</span>]
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">ary</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">k</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-identifier">enc</span>)
    <span class="ruby-identifier">k</span>.<span class="ruby-identifier">scrub!</span>
    <span class="ruby-identifier">v</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-identifier">enc</span>)
    <span class="ruby-identifier">v</span>.<span class="ruby-identifier">scrub!</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">ary</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-decode_www_form_component" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">decode_www_form_component</span><span
                                class="method-args">(str, enc=Encoding::UTF_8)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a string decoded from the given URL-encoded string <code>str</code>.</p>

<p>The given string is first encoded as Encoding::ASCII-8BIT (using String#b), then decoded (as below), and finally force-encoded to the given encoding <code>enc</code>.</p>

<p>The returned string:</p>
<ul><li>
<p>Preserves:</p>
<ul><li>
<p>Characters <code>&#39;*&#39;</code>, <code>&#39;.&#39;</code>, <code>&#39;-&#39;</code>, and <code>&#39;_&#39;</code>.</p>
</li><li>
<p>Character in ranges <code>&#39;a&#39;..&#39;z&#39;</code>, <code>&#39;A&#39;..&#39;Z&#39;</code>, and <code>&#39;0&#39;..&#39;9&#39;</code>.</p>
</li></ul>

<p>Example:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">decode_www_form_component</span>(<span class="ruby-string">&#39;*.-_azAZ09&#39;</span>)
<span class="ruby-comment"># =&gt; &quot;*.-_azAZ09&quot;</span>
</pre>
</li><li>
<p>Converts:</p>
<ul><li>
<p>Character <code>&#39;+&#39;</code> to character <code>&#39; &#39;</code>.</p>
</li><li>
<p>Each “percent notation” to an ASCII character.</p>
</li></ul>

<p>Example:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">decode_www_form_component</span>(<span class="ruby-string">&#39;Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A&#39;</span>)
<span class="ruby-comment"># =&gt; &quot;Here are some punctuation characters: ,;?:&quot;</span>
</pre>
</li></ul>

<p>Related: <a href="URI.html#method-c-decode_uri_component"><code>URI.decode_uri_component</code></a> (preserves <code>&#39;+&#39;</code>).</p>

                              <div class="method-source-code" id="decode_www_form_component-source">
            <pre><span class="ruby-comment"># File uri/common.rb, line 368</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">decode_www_form_component</span>(<span class="ruby-identifier">str</span>, <span class="ruby-identifier">enc</span>=<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>)
  <span class="ruby-identifier">_decode_uri_component</span>(<span class="ruby-regexp">/\+|%\h\h/</span>, <span class="ruby-identifier">str</span>, <span class="ruby-identifier">enc</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-encode_uri_component" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">encode_uri_component</span><span
                                class="method-args">(str, enc=nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Like <a href="URI.html#method-c-encode_www_form_component"><code>URI.encode_www_form_component</code></a>, except that <code>&#39; &#39;</code> (space) is encoded as <code>&#39;%20&#39;</code> (instead of <code>&#39;+&#39;</code>).</p>

                              <div class="method-source-code" id="encode_uri_component-source">
            <pre><span class="ruby-comment"># File uri/common.rb, line 374</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">encode_uri_component</span>(<span class="ruby-identifier">str</span>, <span class="ruby-identifier">enc</span>=<span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">_encode_uri_component</span>(<span class="ruby-regexp">/[^*\-.0-9A-Z_a-z]/</span>, <span class="ruby-constant">TBLENCURICOMP_</span>, <span class="ruby-identifier">str</span>, <span class="ruby-identifier">enc</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-encode_www_form" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">encode_www_form</span><span
                                class="method-args">(enum, enc=nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a URL-encoded string derived from the given Enumerable <code>enum</code>.</p>

<p>The result is suitable for use as form data for an HTTP request whose <code>Content-Type</code> is <code>&#39;application/x-www-form-urlencoded&#39;</code>.</p>

<p>The returned string consists of the elements of <code>enum</code>, each converted to one or more URL-encoded strings, and all joined with character <code>&#39;&amp;&#39;</code>.</p>

<p>Simple examples:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form</span>([[<span class="ruby-string">&#39;foo&#39;</span>, <span class="ruby-value">0</span>], [<span class="ruby-string">&#39;bar&#39;</span>, <span class="ruby-value">1</span>], [<span class="ruby-string">&#39;baz&#39;</span>, <span class="ruby-value">2</span>]])
<span class="ruby-comment"># =&gt; &quot;foo=0&amp;bar=1&amp;baz=2&quot;</span>
<span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form</span>({<span class="ruby-value">foo:</span> <span class="ruby-value">0</span>, <span class="ruby-value">bar:</span> <span class="ruby-value">1</span>, <span class="ruby-value">baz:</span> <span class="ruby-value">2</span>})
<span class="ruby-comment"># =&gt; &quot;foo=0&amp;bar=1&amp;baz=2&quot;</span>
</pre>

<p>The returned string is formed using method <a href="URI.html#method-c-encode_www_form_component"><code>URI.encode_www_form_component</code></a>, which converts certain characters:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form</span>(<span class="ruby-value">&#39;f#o&#39;:</span> <span class="ruby-string">&#39;/&#39;</span>, <span class="ruby-value">&#39;b-r&#39;:</span> <span class="ruby-string">&#39;$&#39;</span>, <span class="ruby-value">&#39;b z&#39;:</span> <span class="ruby-string">&#39;@&#39;</span>)
<span class="ruby-comment"># =&gt; &quot;f%23o=%2F&amp;b-r=%24&amp;b+z=%40&quot;</span>
</pre>

<p>When <code>enum</code> is Array-like, each element <code>ele</code> is converted to a field:</p>
<ul><li>
<p>If <code>ele</code> is an array of two or more elements, the field is formed from its first two elements (and any additional elements are ignored):</p>

<pre class="ruby"><span class="ruby-identifier">name</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form_component</span>(<span class="ruby-identifier">ele</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">enc</span>)
<span class="ruby-identifier">value</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form_component</span>(<span class="ruby-identifier">ele</span>[<span class="ruby-value">1</span>], <span class="ruby-identifier">enc</span>)
<span class="ruby-node">&quot;#{name}=#{value}&quot;</span>
</pre>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form</span>([<span class="ruby-node">%w[foo bar]</span>, <span class="ruby-node">%w[baz bat bah]</span>])
<span class="ruby-comment"># =&gt; &quot;foo=bar&amp;baz=bat&quot;</span>
<span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form</span>([[<span class="ruby-string">&#39;foo&#39;</span>, <span class="ruby-value">0</span>], [<span class="ruby-string">&#39;bar&#39;</span>, <span class="ruby-value">:baz</span>, <span class="ruby-string">&#39;bat&#39;</span>]])
<span class="ruby-comment"># =&gt; &quot;foo=0&amp;bar=baz&quot;</span>
</pre>
</li><li>
<p>If <code>ele</code> is an array of one element, the field is formed from <code>ele[0]</code>:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form_component</span>(<span class="ruby-identifier">ele</span>[<span class="ruby-value">0</span>])
</pre>

<p>Example:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form</span>([[<span class="ruby-string">&#39;foo&#39;</span>], [<span class="ruby-value">:bar</span>], [<span class="ruby-value">0</span>]])
<span class="ruby-comment"># =&gt; &quot;foo&amp;bar&amp;0&quot;</span>
</pre>
</li><li>
<p>Otherwise the field is formed from <code>ele</code>:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form_component</span>(<span class="ruby-identifier">ele</span>)
</pre>

<p>Example:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form</span>([<span class="ruby-string">&#39;foo&#39;</span>, <span class="ruby-value">:bar</span>, <span class="ruby-value">0</span>])
<span class="ruby-comment"># =&gt; &quot;foo&amp;bar&amp;0&quot;</span>
</pre>
</li></ul>

<p>The elements of an Array-like <code>enum</code> may be mixture:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form</span>([[<span class="ruby-string">&#39;foo&#39;</span>, <span class="ruby-value">0</span>], [<span class="ruby-string">&#39;bar&#39;</span>, <span class="ruby-value">1</span>, <span class="ruby-value">2</span>], [<span class="ruby-string">&#39;baz&#39;</span>], <span class="ruby-value">:bat</span>])
<span class="ruby-comment"># =&gt; &quot;foo=0&amp;bar=1&amp;baz&amp;bat&quot;</span>
</pre>

<p>When <code>enum</code> is Hash-like, each <code>key</code>/<code>value</code> pair is converted to one or more fields:</p>
<ul><li>
<p>If <code>value</code> is Array-convertible, each element <code>ele</code> in <code>value</code> is paired with <code>key</code> to form a field:</p>

<pre class="ruby"><span class="ruby-identifier">name</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form_component</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">enc</span>)
<span class="ruby-identifier">value</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form_component</span>(<span class="ruby-identifier">ele</span>, <span class="ruby-identifier">enc</span>)
<span class="ruby-node">&quot;#{name}=#{value}&quot;</span>
</pre>

<p>Example:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form</span>({<span class="ruby-value">foo:</span> [<span class="ruby-value">:bar</span>, <span class="ruby-value">1</span>], <span class="ruby-value">baz:</span> [<span class="ruby-value">:bat</span>, <span class="ruby-value">:bam</span>, <span class="ruby-value">2</span>]})
<span class="ruby-comment"># =&gt; &quot;foo=bar&amp;foo=1&amp;baz=bat&amp;baz=bam&amp;baz=2&quot;</span>
</pre>
</li><li>
<p>Otherwise, <code>key</code> and <code>value</code> are paired to form a field:</p>

<pre class="ruby"><span class="ruby-identifier">name</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form_component</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">enc</span>)
<span class="ruby-identifier">value</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form_component</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">enc</span>)
<span class="ruby-node">&quot;#{name}=#{value}&quot;</span>
</pre>

<p>Example:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form</span>({<span class="ruby-value">foo:</span> <span class="ruby-value">0</span>, <span class="ruby-value">bar:</span> <span class="ruby-value">1</span>, <span class="ruby-value">baz:</span> <span class="ruby-value">2</span>})
<span class="ruby-comment"># =&gt; &quot;foo=0&amp;bar=1&amp;baz=2&quot;</span>
</pre>
</li></ul>

<p>The elements of a Hash-like <code>enum</code> may be mixture:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form</span>({<span class="ruby-value">foo:</span> [<span class="ruby-value">0</span>, <span class="ruby-value">1</span>], <span class="ruby-value">bar:</span> <span class="ruby-value">2</span>})
<span class="ruby-comment"># =&gt; &quot;foo=0&amp;foo=1&amp;bar=2&quot;</span>
</pre>

                              <div class="method-source-code" id="encode_www_form-source">
            <pre><span class="ruby-comment"># File uri/common.rb, line 501</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">encode_www_form</span>(<span class="ruby-identifier">enum</span>, <span class="ruby-identifier">enc</span>=<span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">enum</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">nil?</span>
      <span class="ruby-identifier">encode_www_form_component</span>(<span class="ruby-identifier">k</span>, <span class="ruby-identifier">enc</span>)
    <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:to_ary</span>)
      <span class="ruby-identifier">v</span>.<span class="ruby-identifier">to_ary</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">w</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">str</span> = <span class="ruby-identifier">encode_www_form_component</span>(<span class="ruby-identifier">k</span>, <span class="ruby-identifier">enc</span>)
        <span class="ruby-keyword">unless</span> <span class="ruby-identifier">w</span>.<span class="ruby-identifier">nil?</span>
          <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39;=&#39;</span>
          <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">encode_www_form_component</span>(<span class="ruby-identifier">w</span>, <span class="ruby-identifier">enc</span>)
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">end</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39;&amp;&#39;</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">str</span> = <span class="ruby-identifier">encode_www_form_component</span>(<span class="ruby-identifier">k</span>, <span class="ruby-identifier">enc</span>)
      <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39;=&#39;</span>
      <span class="ruby-identifier">str</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">encode_www_form_component</span>(<span class="ruby-identifier">v</span>, <span class="ruby-identifier">enc</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39;&amp;&#39;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-encode_www_form_component" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">encode_www_form_component</span><span
                                class="method-args">(str, enc=nil)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a URL-encoded string derived from the given string <code>str</code>.</p>

<p>The returned string:</p>
<ul><li>
<p>Preserves:</p>
<ul><li>
<p>Characters <code>&#39;*&#39;</code>, <code>&#39;.&#39;</code>, <code>&#39;-&#39;</code>, and <code>&#39;_&#39;</code>.</p>
</li><li>
<p>Character in ranges <code>&#39;a&#39;..&#39;z&#39;</code>, <code>&#39;A&#39;..&#39;Z&#39;</code>, and <code>&#39;0&#39;..&#39;9&#39;</code>.</p>
</li></ul>

<p>Example:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form_component</span>(<span class="ruby-string">&#39;*.-_azAZ09&#39;</span>)
<span class="ruby-comment"># =&gt; &quot;*.-_azAZ09&quot;</span>
</pre>
</li><li>
<p>Converts:</p>
<ul><li>
<p>Character <code>&#39; &#39;</code> to character <code>&#39;+&#39;</code>.</p>
</li><li>
<p>Any other character to “percent notation”; the percent notation for character <em>c</em> is <code>&#39;%%%X&#39; % c.ord</code>.</p>
</li></ul>

<p>Example:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">encode_www_form_component</span>(<span class="ruby-string">&#39;Here are some punctuation characters: ,;?:&#39;</span>)
<span class="ruby-comment"># =&gt; &quot;Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A&quot;</span>
</pre>
</li></ul>

<p>Encoding:</p>
<ul><li>
<p>If <code>str</code> has encoding Encoding::ASCII_8BIT, argument <code>enc</code> is ignored.</p>
</li><li>
<p>Otherwise <code>str</code> is converted first to Encoding::UTF_8 (with suitable character replacements), and then to encoding <code>enc</code>.</p>
</li></ul>

<p>In either case, the returned string has forced encoding Encoding::US_ASCII.</p>

<p>Related: <a href="URI.html#method-c-encode_uri_component"><code>URI.encode_uri_component</code></a> (encodes <code>&#39; &#39;</code> as <code>&#39;%20&#39;</code>).</p>

                              <div class="method-source-code" id="encode_www_form_component-source">
            <pre><span class="ruby-comment"># File uri/common.rb, line 335</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">encode_www_form_component</span>(<span class="ruby-identifier">str</span>, <span class="ruby-identifier">enc</span>=<span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">_encode_uri_component</span>(<span class="ruby-regexp">/[^*\-.0-9A-Z_a-z]/</span>, <span class="ruby-constant">TBLENCWWWCOMP_</span>, <span class="ruby-identifier">str</span>, <span class="ruby-identifier">enc</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-for" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">for</span><span
                                class="method-args">(scheme, *arguments, default: Generic)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a new object constructed from the given <code>scheme</code>, <code>arguments</code>, and <code>default</code>:</p>
<ul><li>
<p>The new object is an instance of <code>URI.scheme_list[scheme.upcase]</code>.</p>
</li><li>
<p>The object is initialized by calling the class initializer using <code>scheme</code> and <code>arguments</code>. See <a href="URI/Generic.html#method-c-new"><code>URI::Generic.new</code></a>.</p>
</li></ul>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-identifier">values</span> = [<span class="ruby-string">&#39;john.doe&#39;</span>, <span class="ruby-string">&#39;www.example.com&#39;</span>, <span class="ruby-string">&#39;123&#39;</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-string">&#39;/forum/questions/&#39;</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-string">&#39;tag=networking&amp;order=newest&#39;</span>, <span class="ruby-string">&#39;top&#39;</span>]
<span class="ruby-constant">URI</span>.<span class="ruby-identifier">for</span>(<span class="ruby-string">&#39;https&#39;</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">values</span>)
<span class="ruby-comment"># =&gt; #&lt;URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&amp;order=newest#top&gt;</span>
<span class="ruby-constant">URI</span>.<span class="ruby-identifier">for</span>(<span class="ruby-string">&#39;foo&#39;</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">values</span>, <span class="ruby-value">default:</span> <span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>)
<span class="ruby-comment"># =&gt; #&lt;URI::HTTP foo://john.doe@www.example.com:123/forum/questions/?tag=networking&amp;order=newest#top&gt;</span>
</pre>

                              <div class="method-source-code" id="for-source">
            <pre><span class="ruby-comment"># File uri/common.rb, line 123</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-keyword">for</span>(<span class="ruby-identifier ruby-title">scheme</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">arguments</span>, <span class="ruby-value">default:</span> <span class="ruby-constant">Generic</span>)
  <span class="ruby-identifier">const_name</span> = <span class="ruby-identifier">scheme</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">upcase</span>

  <span class="ruby-identifier">uri_class</span> = <span class="ruby-constant">INITIAL_SCHEMES</span>[<span class="ruby-identifier">const_name</span>]
  <span class="ruby-identifier">uri_class</span> <span class="ruby-operator">||=</span> <span class="ruby-keyword">if</span> <span class="ruby-regexp">/\A[A-Z]\w*\z/</span>.<span class="ruby-identifier">match?</span>(<span class="ruby-identifier">const_name</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">Schemes</span>.<span class="ruby-identifier">const_defined?</span>(<span class="ruby-identifier">const_name</span>, <span class="ruby-keyword">false</span>)
    <span class="ruby-constant">Schemes</span>.<span class="ruby-identifier">const_get</span>(<span class="ruby-identifier">const_name</span>, <span class="ruby-keyword">false</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">uri_class</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">default</span>

  <span class="ruby-keyword">return</span> <span class="ruby-identifier">uri_class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">scheme</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">arguments</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-join" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">join</span><span
                                class="method-args">(*str)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Merges the given <a href="URI.html"><code>URI</code></a> strings <code>str</code> per <a href="https://www.rfc-editor.org/rfc/rfc2396.html">RFC 2396</a>.</p>

<p>Each string in <code>str</code> is converted to an <a href="https://www.rfc-editor.org/rfc/rfc3986.html">RFC3986 URI</a> before being merged.</p>

<p>Examples:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;http://example.com/&quot;</span>,<span class="ruby-string">&quot;main.rbx&quot;</span>)
<span class="ruby-comment"># =&gt; #&lt;URI::HTTP http://example.com/main.rbx&gt;</span>

<span class="ruby-constant">URI</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39;http://example.com&#39;</span>, <span class="ruby-string">&#39;foo&#39;</span>)
<span class="ruby-comment"># =&gt; #&lt;URI::HTTP http://example.com/foo&gt;</span>

<span class="ruby-constant">URI</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39;http://example.com&#39;</span>, <span class="ruby-string">&#39;/foo&#39;</span>, <span class="ruby-string">&#39;/bar&#39;</span>)
<span class="ruby-comment"># =&gt; #&lt;URI::HTTP http://example.com/bar&gt;</span>

<span class="ruby-constant">URI</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39;http://example.com&#39;</span>, <span class="ruby-string">&#39;/foo&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span>)
<span class="ruby-comment"># =&gt; #&lt;URI::HTTP http://example.com/bar&gt;</span>

<span class="ruby-constant">URI</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39;http://example.com&#39;</span>, <span class="ruby-string">&#39;/foo/&#39;</span>, <span class="ruby-string">&#39;bar&#39;</span>)
<span class="ruby-comment"># =&gt; #&lt;URI::HTTP http://example.com/foo/bar&gt;</span>
</pre>

                              <div class="method-source-code" id="join-source">
            <pre><span class="ruby-comment"># File uri/common.rb, line 211</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">join</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">str</span>)
  <span class="ruby-constant">RFC3986_PARSER</span>.<span class="ruby-identifier">join</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">str</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-parse" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">parse</span><span
                                class="method-args">(uri)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a new URI object constructed from the given string <code>uri</code>:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-string">&#39;https://john.doe@www.example.com:123/forum/questions/?tag=networking&amp;order=newest#top&#39;</span>)
<span class="ruby-comment"># =&gt; #&lt;URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&amp;order=newest#top&gt;</span>
<span class="ruby-constant">URI</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-string">&#39;http://john.doe@www.example.com:123/forum/questions/?tag=networking&amp;order=newest#top&#39;</span>)
<span class="ruby-comment"># =&gt; #&lt;URI::HTTP http://john.doe@www.example.com:123/forum/questions/?tag=networking&amp;order=newest#top&gt;</span>
</pre>

<p>It’s recommended to first ::escape string <code>uri</code> if it may contain invalid <a href="URI.html"><code>URI</code></a> characters.</p>

                              <div class="method-source-code" id="parse-source">
            <pre><span class="ruby-comment"># File uri/common.rb, line 184</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">parse</span>(<span class="ruby-identifier">uri</span>)
  <span class="ruby-constant">RFC3986_PARSER</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-register_scheme" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">register_scheme</span><span
                                class="method-args">(scheme, klass)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Registers the given <code>klass</code> as the class to be instantiated when parsing a URI with the given <code>scheme</code>:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">register_scheme</span>(<span class="ruby-string">&#39;MS_SEARCH&#39;</span>, <span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">Generic</span>) <span class="ruby-comment"># =&gt; URI::Generic</span>
<span class="ruby-constant">URI</span>.<span class="ruby-identifier">scheme_list</span>[<span class="ruby-string">&#39;MS_SEARCH&#39;</span>]                   <span class="ruby-comment"># =&gt; URI::Generic</span>
</pre>

<p>Note that after calling String#upcase on <code>scheme</code>, it must be a valid constant name.</p>

                              <div class="method-source-code" id="register_scheme-source">
            <pre><span class="ruby-comment"># File uri/common.rb, line 79</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">register_scheme</span>(<span class="ruby-identifier">scheme</span>, <span class="ruby-identifier">klass</span>)
  <span class="ruby-constant">Schemes</span>.<span class="ruby-identifier">const_set</span>(<span class="ruby-identifier">scheme</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">upcase</span>, <span class="ruby-identifier">klass</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-scheme_list" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">scheme_list</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a hash of the defined schemes:</p>

<pre class="ruby"><span class="ruby-constant">URI</span>.<span class="ruby-identifier">scheme_list</span>
<span class="ruby-comment"># =&gt;</span>
{<span class="ruby-string">&quot;MAILTO&quot;</span><span class="ruby-operator">=&gt;</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">MailTo</span>,
 <span class="ruby-string">&quot;LDAPS&quot;</span><span class="ruby-operator">=&gt;</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">LDAPS</span>,
 <span class="ruby-string">&quot;WS&quot;</span><span class="ruby-operator">=&gt;</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">WS</span>,
 <span class="ruby-string">&quot;HTTP&quot;</span><span class="ruby-operator">=&gt;</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>,
 <span class="ruby-string">&quot;HTTPS&quot;</span><span class="ruby-operator">=&gt;</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPS</span>,
 <span class="ruby-string">&quot;LDAP&quot;</span><span class="ruby-operator">=&gt;</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">LDAP</span>,
 <span class="ruby-string">&quot;FILE&quot;</span><span class="ruby-operator">=&gt;</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">File</span>,
 <span class="ruby-string">&quot;FTP&quot;</span><span class="ruby-operator">=&gt;</span><span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">FTP</span>}
</pre>

<p>Related: <a href="URI.html#method-c-register_scheme"><code>URI.register_scheme</code></a>.</p>

                              <div class="method-source-code" id="scheme_list-source">
            <pre><span class="ruby-comment"># File uri/common.rb, line 97</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">scheme_list</span>
  <span class="ruby-constant">Schemes</span>.<span class="ruby-identifier">constants</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span>
    [<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">upcase</span>, <span class="ruby-constant">Schemes</span>.<span class="ruby-identifier">const_get</span>(<span class="ruby-identifier">name</span>)]
  }.<span class="ruby-identifier">to_h</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-split" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">split</span><span
                                class="method-args">(uri)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a 9-element array representing the parts of the URI formed from the string <code>uri</code>; each array element is a string or <code>nil</code>:</p>

<pre class="ruby"><span class="ruby-identifier">names</span> = <span class="ruby-node">%w[scheme userinfo host port registry path opaque query fragment]</span>
<span class="ruby-identifier">values</span> = <span class="ruby-constant">URI</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&#39;https://john.doe@www.example.com:123/forum/questions/?tag=networking&amp;order=newest#top&#39;</span>)
<span class="ruby-identifier">names</span>.<span class="ruby-identifier">zip</span>(<span class="ruby-identifier">values</span>)
<span class="ruby-comment"># =&gt;</span>
[[<span class="ruby-string">&quot;scheme&quot;</span>, <span class="ruby-string">&quot;https&quot;</span>],
 [<span class="ruby-string">&quot;userinfo&quot;</span>, <span class="ruby-string">&quot;john.doe&quot;</span>],
 [<span class="ruby-string">&quot;host&quot;</span>, <span class="ruby-string">&quot;www.example.com&quot;</span>],
 [<span class="ruby-string">&quot;port&quot;</span>, <span class="ruby-string">&quot;123&quot;</span>],
 [<span class="ruby-string">&quot;registry&quot;</span>, <span class="ruby-keyword">nil</span>],
 [<span class="ruby-string">&quot;path&quot;</span>, <span class="ruby-string">&quot;/forum/questions/&quot;</span>],
 [<span class="ruby-string">&quot;opaque&quot;</span>, <span class="ruby-keyword">nil</span>],
 [<span class="ruby-string">&quot;query&quot;</span>, <span class="ruby-string">&quot;tag=networking&amp;order=newest&quot;</span>],
 [<span class="ruby-string">&quot;fragment&quot;</span>, <span class="ruby-string">&quot;top&quot;</span>]]
</pre>

                              <div class="method-source-code" id="split-source">
            <pre><span class="ruby-comment"># File uri/common.rb, line 170</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">split</span>(<span class="ruby-identifier">uri</span>)
  <span class="ruby-constant">RFC3986_PARSER</span>.<span class="ruby-identifier">split</span>(<span class="ruby-identifier">uri</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Class Methods</h3>
                </header>

                  <div id="method-c-_decode_uri_component" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">_decode_uri_component</span><span
                                class="method-args">(regexp, str, enc)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="_decode_uri_component-source">
            <pre><span class="ruby-comment"># File uri/common.rb, line 397</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">_decode_uri_component</span>(<span class="ruby-identifier">regexp</span>, <span class="ruby-identifier">str</span>, <span class="ruby-identifier">enc</span>)
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;invalid %-encoding (#{str})&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-regexp">/%(?!\h\h)/</span>.<span class="ruby-identifier">match?</span>(<span class="ruby-identifier">str</span>)
  <span class="ruby-identifier">str</span>.<span class="ruby-identifier">b</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-identifier">regexp</span>, <span class="ruby-constant">TBLDECWWWCOMP_</span>).<span class="ruby-identifier">force_encoding</span>(<span class="ruby-identifier">enc</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-_encode_uri_component" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">_encode_uri_component</span><span
                                class="method-args">(regexp, table, str, enc)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="_encode_uri_component-source">
            <pre><span class="ruby-comment"># File uri/common.rb, line 383</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">_encode_uri_component</span>(<span class="ruby-identifier">regexp</span>, <span class="ruby-identifier">table</span>, <span class="ruby-identifier">str</span>, <span class="ruby-identifier">enc</span>)
  <span class="ruby-identifier">str</span> = <span class="ruby-identifier">str</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">dup</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">str</span>.<span class="ruby-identifier">encoding</span> <span class="ruby-operator">!=</span> <span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">ASCII_8BIT</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">enc</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">enc</span> <span class="ruby-operator">!=</span> <span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">ASCII_8BIT</span>
      <span class="ruby-identifier">str</span>.<span class="ruby-identifier">encode!</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">UTF_8</span>, <span class="ruby-value">invalid:</span> <span class="ruby-value">:replace</span>, <span class="ruby-value">undef:</span> <span class="ruby-value">:replace</span>)
      <span class="ruby-identifier">str</span>.<span class="ruby-identifier">encode!</span>(<span class="ruby-identifier">enc</span>, <span class="ruby-value">fallback:</span> <span class="ruby-operator">-&gt;</span>(<span class="ruby-identifier">x</span>){<span class="ruby-node">&quot;&amp;##{x.ord};&quot;</span>})
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">str</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">ASCII_8BIT</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">str</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-identifier">regexp</span>, <span class="ruby-identifier">table</span>)
  <span class="ruby-identifier">str</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">US_ASCII</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

